<template>
    <!-- 头部部分 -->
  <header class="header">
    <h1>todos</h1>
    <input class="new-todo" placeholder="请输入任务名称" autofocus v-model="value" @keyup.enter="addFn" />
  </header>
</template>

<script>
export default {
  name: 'SrcTodosMyHeader',

  data() {
    return {
      value:''
    };
  },

  mounted() {
    
  },

  methods: {
    addFn() {
      if (!this.value.trim()) {
        alert('不能为空')
        return
      }
      this.$store.dispatch('todo/addList',{
        name:this.value,
        done:false
      })
    }
  },
};
</script>